/*
 *  Copyright © 2018 - 2021 xulianqiang90@163.com. All Rights Reserved.
 */

package io.light.frame.dal.mybatis.generator.core.meta.entity;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * Table metadata
 *
 * @author Ivan
 * @version 1.0.0
 * @date 2021-05-15 07:17
 */
@Getter
@Setter
@ToString
public class Table implements Metadata{

    /**
     * Database name
     */
    @JSONField(name = "table_cat")
    private String database;

    /**
     * Table name
     */
    @JSONField(name = "table_name")
    private String name;

    /**
     * Table comment
     */
    @JSONField(name = "remarks")
    private String comment;

    /**
     * Table columns
     */
    private List<TableColumn> columns;

    /**
     * Determine metadata is valid or not
     *
     * @return {@code boolean}
     */
    @Override
    public boolean isValid() {
        return StringUtils.isNotBlank(name) && StringUtils.isNotBlank(database);
    }
}
